package cn.kmsoft.jssc.controller;

import cn.kmsoft.common.ResInfo;
import com.alibaba.fastjson.JSON;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : cqwensten
 * @description : todo
 * @email : cqwensten@163.com
 * @date : 2023/1/28
 */
@Log4j2
@Service
public class PythonApi extends BaseController {

    /**
     * 地类还原分析：成果合并
     *
     * @param jobId
     * @return
     */
    public ResInfo doJsscDlhyAnalyst(String jobId, String interfaceName) {
        //http://127.0.0.1:9000/interfaceName
        String url = this.analyseConfig.getPythondomain() + interfaceName;
        ResInfo resInfo = new ResInfo();

        //请求参数
        Map<String, Object> req = new HashMap<String, Object>();
        req.put("jobId", jobId);

        try {
            this.postApi(url, JSON.toJSONString(req));
            resInfo.setStatus(ResInfo.SUCCESS);
            resInfo.setMsg(String.format("%s 任务已提交", jobId));
            resInfo.setRes(jobId);
        }catch(Exception ex) {
            resInfo.setStatus(ResInfo.ERROR);
            resInfo.setMsg(String.format("%s 任务提交失败", jobId));
            resInfo.setRes(jobId);
        }

        return resInfo;
    }
}
